Validation Dataset 2

# log in to the shared server

# use manifest file to import single end sequences
qiime tools import \
  --type "SampleData[SequencesWithQuality]" \
  --input-format SingleEndFastqManifestPhred33V2 \
  --input-path /mnt/datasets/project_2/farm/farm_manifest.tsv \
  --output-path demux_seqs.qza

# copy file demux.qzv file into local storage for viewing
scp root@[server ID]:[file path on the server] [file path on local computer]


# DENOISE
# use Dada2
# use the Phred Quality Score (demux.qzv)
qiime dada2 denoise-single \
  --i-demultiplexed-seqs demux_seqs.qza \
  --p-trim-left 0 \
  --p-trunc-len 150 \
  --o-representative-sequences rep-seqs.qza \
  --o-table table.qza \
  --o-denoising-stats stats.qza

# Visualize DADA2 stats
qiime metadata tabulate \
  --m-input-file stats.qza \
  --o-visualization stats.qzv

# Visualize ASVs stats
qiime feature-table summarize \
  --i-table table.qza \
  --o-visualization table.qzv \
  --m-sample-metadata-file /mnt/datasets/project_2/farm/farm_metadata.tsv

# Convert rep-seqs.qza to a viewable file
qiime feature-table tabulate-seqs \
  --i-data rep-seqs.qza \
  --o-visualization rep-seqs.qzv

# copy the table.qzv file into local storage for viewing
scp root@[server ID]:[file path on the server] [file path on local computer]


# TAXONOMIC ANALYSIS
# use the silva classifier (more complete); do not need to train the classifier because V4 is used in sequencing
qiime feature-classifier classify-sklearn \
  --i-classifier /mnt/datasets/classifiers/silva-138-99-515-806-nb-classifier.qza \
  --i-reads rep-seqs.qza \
  --o-classification taxonomy.qza

# visualize the table
qiime metadata tabulate \
  --m-input-file taxonomy.qza \
  --o-visualization taxonomy.qzv

# generate taxonomy barplots
qiime taxa barplot \
  --i-table table.qza \
  --i-taxonomy taxonomy.qza \
  --m-metadata-file /mnt/datasets/project_2/farm/farm_metadata.tsv \
  --o-visualization taxa-bar-plots.qzv


# FILTERING
# at this stage, filter out only the mitochondrial and chloroplast DNA
qiime taxa filter-table \
  --i-table table.qza \
  --i-taxonomy taxonomy.qza \
  --p-exclude mitochondria,chloroplast \
  --o-filtered-table filtered_table.qza

# PHYLOGENETIC TREE
# create a phylogenetic tree using the ASVs
qiime phylogeny align-to-tree-mafft-fasttree \
  --i-sequences rep-seqs.qza \
  --o-alignment aligned-rep-seqs.qza \
  --o-masked-alignment masked-aligned-rep-seqs.qza \
  --o-tree unrooted-tree.qza \
  --o-rooted-tree rooted-tree.qza


# EXPORTING FILES FOR PHYLOSEQ OBJECT
# exporting table.qza file
qiime tools export \
--input-path /data/new_farm/table.qza \
--output-path table_export 

# exporting taxonomy.qza
qiime tools export \
--input-path /data/new_farm/taxonomy.qza \
--output-path taxonomy_export 

# exporting the rooted tree
qiime tools export \
--input-path /data/new_farm/rooted-tree.qza \
--output-path rooted_tree_export

# change directory to table_export
# convert the .biom file into .txt file
biom convert \
-i feature-table.biom \
--to-tsv \
-o feature-table.txt

# copy the mpt_export directory to the local computer
# but move into the right directory first
scp -r root@[server ID]:~[file path on the server] .